package com.primeton.eos.oss.model.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.eos.system.utility.PageResultList;
import com.primeton.components.rest.annotation.MultiRequestBody;
import com.primeton.eos.oss.model.newdataset.CrecAccount;
import com.primeton.eos.oss.model.service.CrecAccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

@Api(tags = "CrecAccount管理")
@RestController
@RequestMapping(value = "/api/oss/model/crecaccounts", consumes = { MediaType.APPLICATION_JSON_UTF8_VALUE }, produces = {
        MediaType.APPLICATION_JSON_UTF8_VALUE })
public class CrecAccountController {

    @Autowired
    private CrecAccountService crecAccountService;

    @ApiOperation("新增CrecAccount")
    @PostMapping
    public void createCrecAccount(@ApiParam("CrecAccount信息") @MultiRequestBody CrecAccount crecAccount) {
        crecAccountService.createCrecAccount(crecAccount);
    }
    
    @ApiOperation("修改CrecAccount")
    @PutMapping
    public void modifyCrecAccount(@ApiParam("CrecAccount信息") @MultiRequestBody CrecAccount crecAccount) {
        crecAccountService.modifyCrecAccount(crecAccount);
    }
    
    @ApiOperation("删除CrecAccount")
    @DeleteMapping
    public void removeCrecAccount(@ApiParam("CrecAccount信息") @MultiRequestBody CrecAccount[] crecAccount) {
        crecAccountService.removeCrecAccount(crecAccount);
    }
    
    @ApiOperation("获取CrecAccount")
    @GetMapping("/{id}")
    public CrecAccount getCrecAccountById(@ApiParam("唯一标识") @PathVariable(name = "id") String id) {
        return crecAccountService.getCrecAccountById(id);
    }
    @ApiOperation("根据条件查询CrecAccount")
    @GetMapping(consumes = MediaType.ALL_VALUE)
    public PageResultList<CrecAccount> queryCrecAccountsByCriteria(
		    @ApiParam("账号名") @RequestParam(name = "username", required = false) String username,
            @ApiParam("每页条数") @RequestParam(name = "pageSize", required = false) int pageSize,
            @ApiParam("当前页数") @RequestParam(name = "pageIndex", required = false) int pageIndex) {
        return crecAccountService.queryCrecAccountsWithPage(username,  pageSize, pageIndex);
    }
}









